package de.jonasblatt.networkapi.rpi.model.gpio;


public class LedBlinker implements Runnable {

	private GpioWorker gpioworker;
	private String gpio;
	private int times;
	private long wait;

	public LedBlinker(GpioWorker gpioworker, String gpio, int times, long wait) {
		super();
		this.gpioworker = gpioworker;
		this.gpio = gpio;
		this.times = times;
		this.wait = wait;
	}

	@Override
	public void run() {
		for (int i = 0; i < this.times; i++) {
			this.gpioworker.setGpioOn(this.gpio);
			try {
				Thread.sleep(this.wait);
			} catch (InterruptedException e1) {
				e1.printStackTrace();
			}
			this.gpioworker.setGpioOff(this.gpio);
			try {
				Thread.sleep(this.wait);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

	}

}
